package team.yidong.fenda.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import team.yidong.fenda.entity.SysUserPermission;

import java.util.List;

/**
 * Created by xuanlong on 2018/1/28.
 */
@Repository
public interface SysUserPermissionRepository extends JpaRepository<SysUserPermission, Integer> {
    SysUserPermission findByPermission(String name);

    @Query("select  permission from SysUserPermission permission where permission.id=?1 and permission.resourceType=?2")
    SysUserPermission findByIdAndResourceType(Integer id, String resourceType);

    @Query("select  permission from SysUserPermission permission where permission not in ?1 and permission.resourceType=?2")
    List<SysUserPermission> findRestPermission(List<SysUserPermission> sysUserPermissionList, String resourceType);

    List<SysUserPermission> findByResourceType(String resourceType);
}
